package com.yzd.netmonitor.web;

import java.util.Date;

public class RespBody {

	private int code = ResponseCode.CODE_200.getCode();

	private String message;

	private long time;

	private Object result;

	public RespBody() {

		this(ResponseCode.CODE_200);
	}

	public RespBody(ResponseCode code, Object result) {

		this(code.getCode(), code.getDesp(), result);
	}

	private RespBody(int code, String msg, Object result) {

		this.code = code;
		this.message = msg;
		this.result = result;
	}

	public RespBody(ResponseCode code, Throwable e) {

		this.code = code.getCode();
		this.message = code.getDesp();
		this.result = e;
	}

	public RespBody(ResponseCode code, String message, Object result) {

		this(code.getCode(), message, result);
	}

	public RespBody(ResponseCode code) {

		this(code, null);
	}

	public int getCode() {

		return code;
	}

	public void setCode(int code) {

		this.code = code;
	}

	public String getMessage() {

		return message;
	}

	public void setMessage(String message) {

		this.message = message;
	}

	public Long getTime() {

		if (time == 0) {
			return new Date().getTime();
		}
		return time;
	}

	public void setTime(Long time) {

		this.time = time;
	}

	public Object getResult() {

		return result;
	}

	public void setResult(Object result) {

		this.result = result;
	}
}
